package com.softaria.windows.widgets;

import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
import com.softaria.windows.styles.LeftPanelStyles;

public class LeftPanel extends Grid implements LeftPanelStyles {

  private DecoratorPanel bottomDecorPanel;
  private DecoratorPanel topDecorPanel;

  public LeftPanel() {
    super(2, 1);
    setCellPadding(0);
    setCellSpacing(0);

    setStylePrimaryName(LEFT_PANEL_STYLE);

    this.getCellFormatter().addStyleName(0, 0, LEFT_PANEL_TOP_TD);
    this.getCellFormatter().addStyleName(1, 0, LEFT_PANEL_BOTTOM_TD);

    this.getRowFormatter().addStyleName(0, LEFT_PANEL_TOP_TR);
    this.getRowFormatter().addStyleName(1, LEFT_PANEL_BOTTOM_TR);

    topDecorPanel = new DecoratorPanel();
    topDecorPanel.setStylePrimaryName(LEFT_PANEL_TOP_STYLE);
    setWidget(0, 0, topDecorPanel);

    bottomDecorPanel = new DecoratorPanel();
    bottomDecorPanel.setStylePrimaryName(LEFT_PANEL_BOTTOM_STYLE);
    setWidget(1, 0, bottomDecorPanel);

  }

  public void setTopWidget(Widget widget) {
    ScrollPanel topScrollPanel = new ScrollPanel(widget);
    topDecorPanel.add(topScrollPanel);
  }

  public void setBottomWidget(Widget widget) {
    bottomDecorPanel.clear();
    bottomDecorPanel.add(widget);
  }
}
